<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

//middleware 中间件， prefix url前缀， namespace 控制器命名空间
Route::middleware('web')->prefix('posts')->group(function () {
    //文章列表页路由
    Route::get('/', 'PostController@index');
    //创建文章
    Route::get('/create', 'PostController@create');
    Route::post('/', 'PostController@store');
    //搜索页
    Route::get('/search','PostController@search');
    //文章详情页
    Route::get('{post}', 'PostController@show');
    //编辑文章
    Route::get('{post}/edit', 'PostController@edit');
    Route::put('{post}', 'PostController@update');
    //删除文章
    Route::get('{post}/delete', 'PostController@delete');
    //图片上传
    Route::post('/image/upload','PostController@imageUpload');
    //评论提交的路由
    Route::post('{post}/comment','PostController@comment');
    //赞和取消赞
    Route::get('{post}/zan','PostController@zan');
    Route::get('{post}/unzan','PostController@unzan');
});

// 专题
Route::get('/topic/{topic}', '\App\Http\Controllers\TopicController@show');
Route::post('/topic/{topic}/submit', '\App\Http\Controllers\TopicController@submit');

//用户组件的路由
Route::middleware('web')->group(function () {
    //注册页面
    Route::get('/register', 'RegisterController@index');
    //注册行为
    Route::post('/register', 'RegisterController@register');
    //登陆页面
    Route::get('/login', 'LoginController@index');
    //登陆行为
    Route::post('/login', 'LoginController@login');
    //登出行为
    Route::get('/logout', 'LoginController@logout');
    //个人设置页面
    Route::get('/user/me/setting', 'UserController@setting');
    //个人设置操作
    Route::post('/user/me/setting', 'UserController@settingStore');
    //个人中心
    Route::get('/user/{user}', 'UserController@show');
    //关注
    Route::post('/user/{user}/fan', 'UserController@fan');
    //取消关注
    Route::post('/user/{user}/unfan', 'UserController@unfan');
});

include_once ('admin.php');
